import 'package:flutter/material.dart';

class OneCountDemo extends StatefulWidget{
  @override 
 _MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<OneCountDemo>{
  int count = 0;
 
  @override 
  Widget build (BuildContext context){
    
    return Scaffold(
      appBar: AppBar(title: Text('this is my frist app'),),
      body: Center(
        child:Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('您点击了几下',style: TextStyle(fontSize: 30.0),),
            Text('$count下',style: TextStyle(fontSize: 25.0,color: Color(0xff000000),fontWeight: FontWeight.w600),),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children:<Widget>[
                Container(
                  margin: EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0),
                  color: Colors.redAccent,
                  child:IconButton(
                    icon: Icon(Icons.add),
                    // color: Colors.lightBlue,
                    splashColor:Colors.white,
                    highlightColor:Colors.white,
                    onPressed:(){
                      setState(() {
                            count++;
                      });
                    },
                  ),
                ),
                Container(
                  color: Colors.lightBlue,
                  child:IconButton(
                    icon: Icon(Icons.remove),
                   splashColor:Colors.white,
                    highlightColor:Colors.white,
                    onPressed:(){
                      setState(() {
                        if (count<=0) return;
                        count--;
                      });
                    },
                  ), 
                ),
              ]
            ),
            FlatButton(
              child: Text('跳转到另一个页面'),
              onPressed: (){
                Navigator.push(context, MaterialPageRoute(builder: (context)=>SeconedDemo()));
              },
            )
          ],
        ), 
      ),
    );
  }
}
class SeconedDemo extends StatelessWidget{
  @override 
  Widget build(BuildContext context){
    return Scaffold(
      appBar: AppBar(title:Text('jaksfjashf'),),
      body: Center(child: Text('这是路由后的页面'),),
    );
  }
}